package com.springdoor.common.core.domain;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.springdoor.common.core.domain.entity.*;

import static java.awt.SystemColor.menu;

/**
 * Treeselect树结构实体类
 * 
 * @author ruoyi
 */
public class TreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点值 */
    private String value;

    /** 节点名称 */
    private String label;

    /** 是否禁用 */
    private Boolean disabled;

    /** 属性 */
    private Object object;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }

    public TreeSelect(SysDept dept)
    {
        this.id = dept.getDeptId();
        this.value = dept.getDeptId() + "";
        this.label = dept.getDeptName();
        if (!"0".equals(dept.getDelFlag())) {
            this.disabled = true;
        }
        SysDept d = new SysDept();
        d.setDeptId(dept.getDeptId());
        d.setDeptName(dept.getDeptName());
        d.setIsShop(dept.getIsShop());
        this.object = d;
        this.disabled = !"0".equals(dept.getDelFlag());
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(SysMenu menu)
    {
        this.id = menu.getMenuId();
        this.value = menu.getMenuId() + "";
        this.label = menu.getMenuName();
        if (!"0".equals(menu.getStatus())) {
            this.disabled = true;
        }
        this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(SprdGoodsAttr attr)
    {
        this.id = attr.getAttrId();
        this.value = attr.getAttrId() + "";
        this.label = attr.getAttrName();
        if ("0".equals(attr.getDelFlag())) {
            this.disabled = false;
        } else {
            this.disabled = true;
        }
        this.object = attr;
        this.children = attr.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(SprdGoodsBrand brand)
    {
        this.id = brand.getBrandId();
        this.value = brand.getBrandId() + "";
        this.label = brand.getBrandName();
        if ("0".equals(brand.getDelFlag())) {
            this.disabled = false;
        } else {
            this.disabled = true;
        }
        this.children = brand.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(SprdGoodsType type)
    {
        this.id = type.getgTypeId();
        this.value = type.getgTypeId() + "";
        this.label = type.getgTypeName();
        if ("0".equals(type.getDelFlag())) {
            this.disabled = false;
        } else {
            this.disabled = true;
        }
        this.children = type.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public Boolean getDisabled() {
        return disabled;
    }

    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    public List<TreeSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelect> children)
    {
        this.children = children;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }
}
